#include <iostream>
#include <queue>
using namespace std;

const int NMAX = 10;

struct Queue
{ int a[NMAX];
  int n;
  int first, last;
  Queue()
  { n=0; first=last=0; }
};

void push(Queue &q,int x)
{ if(q.n<NMAX)
  { if(q.n>0) q.last++;
    if(q.last==NMAX) q.last=0;
    q.a[q.last]=x;
    q.n++;
  }
}  

void pop(Queue &q)
{ if(q.n>0)
  { q.first++;
    if(q.first==NMAX) q.first=0;
    q.n--;
    if(q.n==0) { q.first=q.last=0; }
  }
}  

int front(Queue &q)
{ return q.a[q.first];
}  

int size(Queue q)
{ return q.n; }

bool empty(Queue q)
{ return q.n==0; }


int main()
{ Queue q;

  push(q,10); push(q,15); push(q,12);
  cout << front(q) << endl;
  cout << size(q) << endl;
  pop(q);
  cout << front(q) << endl;
  cout << size(q) << endl;
  push(q,30);
  
  while(!empty(q))
  { cout << front(q) << " ";
    pop(q);
  }  
  cout << endl;
 
  return 0;
}    
    
  
